﻿Console = function (evaluationFunction) {
    this.currentId = 0;
    this.evaluationFunction = evaluationFunction;
};

Console.prototype.ExecuteCommand = function () {

    // add a new line of output to the console
    $("#prompt").before($("#templates > #lineItemTemplate").clone());

    // change the id
    this.currentId++;
    var newId = "entry" + this.currentId;
    $("#console > #lineItemTemplate").attr("id", newId);
    
    // run command
    var commandInput = $("#consoleInput").val();
    var commandOutput = this.evaluationFunction(commandInput);

    // fill contents
    $("#console > #" + newId + "> .echoCommand").html(commandInput);
    $("#console > #" + newId + "> .consoleOutput").html(commandOutput);

    // clear input and scroll
    $("#consoleInput").val("");
    window.scrollTo(0, $(document).height());
};

Console.prototype.WriteLine = function (output) {
    
};

ConsoleInput = function () {
    this.Command = "";
};



